<?php
class GoodsModel extends Model{
	protected $table = 'goods';
	
	public function getGoods() {
		$sql  = "select b.goods_id,b.goods_name,a.cate_name,b.goods_desc,b.market_price,b.shop_price,b.goods_img from
category a inner join goods b on a.cate_id = b.cate_id where a.del_flag = 0 and
b.del_flag = 0;";
		return $this -> db -> getRow($sql);
	}
	
	public function getGoodsRow($goodsId) {
		$sql  = "select goods_id,goods_name,goods_desc,cate_id,market_price,shop_price from {$this -> table} where goods_id = :goods_id";
		$data = array(':goods_id' => $goodsId);
		return $this -> db -> getRow($sql, $data);
	}
	
	public function delGoods($goodsId) {
		return $this -> db ->autoExecute($this -> table, array('del_flag' => 1), "where goods_id = {$goodsId}", 'update');
	}
}
?>